package com.yanqu.road.server.cmd.orewar;

import com.yanqu.road.entity.crossorewar.CrossUserOrePit;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.orewar.OreWarProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.orewar.CrossOreWarMgr;
import com.yanqu.road.server.pb.orewar.CrossOreWarPb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import java.util.List;


@Cmd(code = Protocol.C_CROSS_ORE_WAR_PIT_LIST, desc = "获取坑位详细信息")
public class CrossOreWarPitListCmd extends CrossUnionCommand {

    private int activityId;

    private int startPitId;

    private int endPitId;

    private long userId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        OreWarProto.CrossOreGetStationDetailReqMsg reqMsg = OreWarProto.CrossOreGetStationDetailReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        startPitId = reqMsg.getStartPitId();
        endPitId = reqMsg.getEndPitId();
        userId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        List<CrossUserOrePit> crossPitList  = CrossOreWarMgr.getCrossUserOrePitList(activityId,startPitId,endPitId,groupId);
        OreWarProto.CrossOrePitListMsg.Builder respMsg = CrossOreWarPb.parseCrossOrePitListMsg(crossPitList);
        respMsg.setActivityId(activityId);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(Protocol.S_CROSS_ORE_WAR_PIT_LIST, respMsg);
        MessageHelper.sendPacket(serverId, userId, pbMsg);
    }

    @Override
    public void sendData() {

    }
}
